package com.jy.datapipeline.importserver.controller;

import com.jy.datapipeline.export.entity.DataDictionary;
import com.jy.datapipeline.export.service.DataDictionaryService;
import com.jy.datapipeline.common.vo.ReturnVo;
import com.jy.datapipeline.importserver.entity.ImportDirection;
import com.jy.datapipeline.importserver.service.ImportDirectionService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @类名 ImportDicController
 * @描述 TODO
 * @作者 白条君
 * @创建日期 2023/4/17 16:15
 * @版本 1.0
 */
@RestController
@RequestMapping("/dic")
public class ImportDicController {
    
    private final ImportDirectionService importDirectionService;

    private final DataDictionaryService dataDictionaryService;

    public ImportDicController(ImportDirectionService importDirectionService,
                               DataDictionaryService dataDictionaryService) {
        this.importDirectionService = importDirectionService;
        this.dataDictionaryService = dataDictionaryService;
    }

    @GetMapping("/query-by-type")
    public ReturnVo queryDicData(@RequestParam String type) {
        List<ImportDirection> importDirections = importDirectionService.queryDicData(type);
        return ReturnVo.ok().put(importDirections);
    }

    @GetMapping("/query-city-code")
    public ReturnVo queryCityCodes(@RequestParam String type) {
        List<DataDictionary> list= this.dataDictionaryService.findByType(type);
        return ReturnVo.ok().put(list);
    }
}
